/**
 * 北京中流科技有限公司 版权所有
 * http://www.chinasoa.com.cn
 */
package cn.com.chinasoa.course.subscribe.test;

import java.util.Iterator;
import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.Query;

import cn.com.chinasoa.course.subscribe.model.TrainingCondition;
import cn.com.chinasoa.course.subscribe.model.TrainingSubject;
import cn.com.chinasoa.course.subscribe.util.EntityManagerHelper;

/**
 * @author 刘洋(liuyang@chinasoa.com.cn)
 * 2007-10-31上午04:01:58
 */
public class TrainingSubjectQuery {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		EntityManager em = EntityManagerHelper.getEntityManager();
		em.getTransaction().begin();
		Query q = em.createQuery("select t from TrainingSubject t");
		List rs = q.getResultList();
		for(Iterator it = rs.iterator();it.hasNext();){
			Object obj = it.next();
			TrainingSubject ts = (TrainingSubject)obj;
			System.out.println("id="+ts.getId()+";TrainingConditions="+ts.getTrainingConditions().size());
			for(Iterator tcit = ts.getTrainingConditions().iterator();tcit.hasNext();){
				TrainingCondition tc = (TrainingCondition)tcit.next();
				System.out.println("Qualification = "+tc.getQualification());
			}
		}
		em.getTransaction().commit();
		EntityManagerHelper.closeEntityManager();

	}

}
